package com.huyanqi.front.rest.resource.impl;

import javax.annotation.Resource;

import com.huyanqi.core.RetdObj;
import com.huyanqi.entity.Praise;
import com.huyanqi.front.rest.RespCode;
import com.huyanqi.front.rest.resource.PraiseListResource;
import com.huyanqi.front.rest.resp.PraiseSimpleResp;
import com.huyanqi.front.rest.service.PraiseRestService;

public class PraiseResourceImpl implements PraiseListResource{

	private PraiseRestService restService;
	
	@Resource(name="PraiseRestService")
	public void setRestService(PraiseRestService restService) {
		this.restService = restService;
	}
	public PraiseRestService getRestService() {
		return restService;
	}
	@Override
	public PraiseSimpleResp toPraise(Long uid, Integer type, Long id) {
		PraiseSimpleResp psr = new PraiseSimpleResp();
		RetdObj<Praise> retd = restService.toPraise(uid,type,id);
		if(retd.getRealObj()!=null){
			psr.setResult(retd.getRealObj());
			psr.setCode(RespCode.valueOf(retd.getCode()));
		}else {
			psr.setCode(RespCode.valueOf(retd.getCode()));
		}
		return psr;
	}
	
}
